// ==UserScript==
// @name           shackGreenNewMessages
// @namespace      http://filthysock.com/greasemonkey
// @description    Turns the shackmessages green when you have a new message, will eventually do popup
// @include        http://shacknews.com/*
// @include        http://*.shacknews.com/*
// ==/UserScript==

/*
	REVISIONS: 
	
	2009-10-23 ThomW
		* Got working with updated Chrome Extension 
		* Moved CSS into shackscripts.css.  Now using body.youvegotmail for activation.

*/ 

if (script_enabled('shack_message_notify') == "true") 
{
	// returns first element matching className
	function getElementByClassName(oElm, strTagName, strClassName) 
	{
		var arrElements = oElm.getElementsByTagName(strTagName);
		var oElement;
		for (var i = 0; i < arrElements.length; i++) 
		{
			oElement = arrElements[i];
			if (oElement.className.indexOf(strClassName) == 0) 
			{
				return oElement;
			}
		}
	}
	
	shackmessages = getElementByClassName(document.getElementById("masthead"), "div", "shackmessages");
	if (shackmessages) 
	{
		new_messages = shackmessages.getElementsByTagName("span")[0];
		if (new_messages.innerText != "0") 
		{
			document.getElementsByTagName('body')[0].className += ' youvegotmail'; 
		}
	}
	
}